package com.stadium.service.impl;

import java.util.List;
import java.util.Map;
import java.util.UUID;

import com.stadium.common.utils.SqlMapper;
import com.stadium.common.utils.UserUtils;
import com.stadium.dto.GameCategoryDto;
import com.stadium.entity.GameCategory;
import com.stadium.mapper.GameCategoryMP;
import com.stadium.service.GameCategorySV;
import com.stadium.vo.GameCategoryVo;
import com.stadium.vo.searchVo.GameCategorySearchVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class GameCategorySVI implements GameCategorySV {
    @Autowired
    private GameCategoryMP mapper;
    @Autowired
    private SqlMapper sqlMapper;

    @Override
    public List<GameCategory> queryBySQL(String sql, Map<String, Object> map) {
        return sqlMapper.selectList(sql, map, GameCategory. class);
    }

    @Override
    public void save(GameCategoryVo gameCategoryVo) {
        GameCategory gameCategory =new  GameCategory();
        BeanUtils.copyProperties(gameCategoryVo,gameCategory);
        String id = UUID.randomUUID().toString().replaceAll("-", "");
                                                                                                                                                                                                                                                                        gameCategory.setCreateUser(UserUtils.getUserId());
                                                                        gameCategory.setUpdateUser(UserUtils.getUserId());
                                        gameCategory.setId(id);
        mapper.save(gameCategory);
    }

    @Override
    public void update(GameCategoryVo gameCategoryVo) {
        GameCategory gameCategory =new  GameCategory();
        BeanUtils.copyProperties(gameCategoryVo,gameCategory);
        gameCategory.setUpdateUser(UserUtils.getUserId());
        mapper.update(gameCategory);
    }

    @Override
    public void saveBatch(List<GameCategory> list) {
        mapper.saveBatch(list);
    }

    @Override
    public void delete(String id) {
        mapper.delete(id);
    }

    @Override
    public void deleteBatch(String[] ids) {
        mapper.deleteBatch(ids);
    }


    @Override
    public List<GameCategoryDto> query(GameCategorySearchVo searchVo) {
        return mapper.query(searchVo);
    }

    @Override
    public GameCategoryDto get(String id) {
        return mapper.get(id);
    }

    @Override
    public int getCount(GameCategorySearchVo searchVo) {
        return mapper.getCount(searchVo);
    }

}
